package Maze::Mazes;

our $ISA = qw/Maze/;
use strict;
use warnings;
sub new{
	my $class = shift;
	my $self = {
		my_x=>0,
		my_y=>0,
	};	
	bless $self, $class;
	return $self;
}
sub read_maze{
	my $self = shift;
	my $file2 = shift;
	open FILE, $file2 or die $!;
	my @maze;
	my $l_num = 0;
	my $found = undef;
	my $len = length($line);
	while(my $line = <FILE>){
		chomp($line);
		for(my $i = 0; $i < $len; $i++){
			my $tmp = substr($line, $i, 1);	
			$maze[$l_num][$i] = $tmp;
			if (!($tmp == 0 || $tmp == 1)){print "you fucker! Wrong file! $tmp"}
			if(!$found){
				if($tmp == 1){
					if($i == 00 || $i == $len-1 || $l_num == 0){
						$self->{entrance} = [$i, $l_num];
						$found = 1;
					}
				}
				 }
				 }
		$l_num++;
		if(!$found){
			for(my $i = 0; $i < $len; i++){
				#implement check of botton line!.
		}
		}
		my $bla = length($line);
		$self->{my_y} = $bla;
	}
	$self->{my_x} = $l_num;
	$self->{maze} = \@maze;
	close FILE;
}
sub find_path{
	my $self = shift;
	if(!(defined($self->{entrance}))){
		print "Entrance not found!";
		return;
	}
	
}
sub print_maze{
	my $self = shift;
	my $t_x = $self->{my_x};
	my $t_y = $self->{my_y};
	for(my $i = 0; $i < $t_x; $i++){
		for(my $j = 0; $j < $t_y; $j++){
			print $self->{maze}[$i][$j];	
		}
	print "\n";
	}
	print "Entrance at: $self->{entrance}[0], $self->{entrance}[1]\n";
}
1;
